﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using BOSS.Framework.Search.UrlBuilder;

namespace BOSS.Framework.Search.Context
{
    /// <summary>
    /// 数值范围过滤条件类
    /// </summary>
    [Serializable]
    public class RangeNumberFilterPart : RangeValueFilterPart<decimal>
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="minValue"></param>
        /// <param name="includeMinValue"></param>
        /// <param name="maxValue"></param>
        /// <param name="includeMaxValue"></param>
        public RangeNumberFilterPart(string fieldName, decimal minValue, bool includeMinValue, decimal maxValue, bool includeMaxValue)
        {
            this.FieldName = fieldName;
            this.MinValue = minValue;
            this.IncludeMinValue = includeMinValue;
            this.MaxValue = maxValue;
            this.IncludeMaxValue = includeMaxValue;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="minValue"></param>
        /// <param name="includeMinValue"></param>
        /// <param name="maxValue"></param>
        /// <param name="includeMaxValue"></param>
        public RangeNumberFilterPart(string fieldName, int minValue, bool includeMinValue, int maxValue, bool includeMaxValue)
        {
            this.FieldName = fieldName;
            this.MinValue = minValue;
            this.IncludeMinValue = includeMinValue;
            this.MaxValue = maxValue;
            this.IncludeMaxValue = includeMaxValue;
        }

        /// <summary>
        /// 构造 URL
        /// </summary>
        /// <param name="urlBuilder"></param>
        public override void BuildUrl(IUrlBuilder urlBuilder)
        {
            urlBuilder.SetFilter(this.FieldName, this.MinValue, this.IncludeMinValue, this.MaxValue, this.IncludeMaxValue);
        }
    }
}
